# import java
class {"java":}
exec {"echo $(pwd)"}
# exec { "puppet:///modules/load-paas-exec.rb":}
file { ["/opt", "/opt/miniPaaS/", "/opt/miniPaaS/loadtest"]: ensure => "directory",}

file { "/opt/miniPaaS/loadtest/rbe.jar":
      source => "puppet://modules/loadtest/rbe.jar"
    }

file { "/opt/miniPaaS/loadtest/load-paas-exec.rb":
      source => "puppet://modules/loadtest/load-paas-exec.rb"
    }

exec {"load-paas-exec.rb rbe1.properties": path => "/opt/miniPaaS/loadtest",}


def start_load_tester
		log_file = "#{Time.now.gmtime.inspect.gsub(/\ /,"-")}.log"
		puts "log file: /root/loadtest/log/#{log_file}"
		server_ip =  @t.get_server_current_instance_settings_by_name(@deployment_name,"load-2")["ip_address"]
		Net::SSH.start( "ec2-#{server_ip.gsub(/\./,"-")}.compute-1.amazonaws.com" , 'root' ) do |session|
		    #~ session.process.popen3( "ls /" ) do |input, output, error|
			 #~ end				 
			session.open_channel do |channel|
				channel.on_data do |ch, data|
				  puts "#{data}"
				end
				channel.exec "cd /root/loadtest;"+
					"nohup java -cp rbe.jar generalRBE.RBEGeneral > log/#{log_file} &"				
			 end #session				 
		 end # ssh
		@current_running_experiment_load_log = 	"/root/loadtest/log/#{log_file}"
		return @current_running_experiment_load_log		 
	end	
	
